import axios from "axios";
import { RegisterUser } from "./types";

const axiosInstance = axios.create({
  baseURL: "http://localhost:3005/",
  timeout: 3000,
});
axiosInstance.interceptors.response.use(
  (response) => {
    return response;
  },
  async (error) => {
    console.log(error);
    return error.response;
  }
);
// 登录
export async function login(data: Record<string, any>) {
  return axiosInstance.post("/user/login", data);
}
// 注册发送验证码
export async function registerCaptcha(email: string) {
  return axiosInstance.get("/user/registerCaptcha", {
    params: {
      address: email,
    },
  });
}
export async function register(registerUser: RegisterUser) {
  return axiosInstance.post("/user/register", registerUser);
}
